﻿Imports System.Windows.Forms
Imports TodoMicroSolutionPackV1.dal.dao
Imports NHibernate.Validator.Engine
Imports NHibernate.Validator.Cfg

Public Class frmMain

    Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs)
        ' Create a new instance of the child form.
        Dim ChildForm As New System.Windows.Forms.Form
        ' Make it a child of this MDI form before showing it.
        ChildForm.MdiParent = Me

        m_ChildFormNumber += 1
        ChildForm.Text = "Window " & m_ChildFormNumber

        ChildForm.Show()
    End Sub

    Private Sub OpenFile(ByVal sender As Object, ByVal e As EventArgs)
        Dim OpenFileDialog As New OpenFileDialog
        OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
        OpenFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
        If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
            Dim FileName As String = OpenFileDialog.FileName
            ' TODO: Add code here to open the file.
        End If
    End Sub

    Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim SaveFileDialog As New SaveFileDialog
        SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
        SaveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"

        If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
            Dim FileName As String = SaveFileDialog.FileName
            ' TODO: Add code here to save the current contents of the form to a file.
        End If
    End Sub


    Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        Me.Close()
    End Sub

    Private Sub CutToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' Use My.Computer.Clipboard to insert the selected text or images into the clipboard
    End Sub

    Private Sub CopyToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' Use My.Computer.Clipboard to insert the selected text or images into the clipboard
    End Sub

    Private Sub PasteToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        'Use My.Computer.Clipboard.GetText() or My.Computer.Clipboard.GetData to retrieve information from the clipboard.
    End Sub

    Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        Me.LayoutMdi(MdiLayout.Cascade)
    End Sub

    Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        Me.LayoutMdi(MdiLayout.TileVertical)
    End Sub

    Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        Me.LayoutMdi(MdiLayout.TileHorizontal)
    End Sub

    Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        Me.LayoutMdi(MdiLayout.ArrangeIcons)
    End Sub

    Private Sub CloseAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        ' Close all child forms of the parent.
        For Each ChildForm As Form In Me.MdiChildren
            ChildForm.Close()
        Next
    End Sub

    Private m_ChildFormNumber As Integer

    Private Sub ContrareembolsoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContrareembolsoToolStripMenuItem.Click
        frmCartonContrareembolsoCA.MdiParent = Me
        frmCartonContrareembolsoCA.Show()
    End Sub

    Private Sub EntidadesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EntidadesToolStripMenuItem.Click
        frmABMEntidades.MdiParent = Me
        frmABMEntidades.Show()
    End Sub

    Private Sub ProductosToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductosToolStripMenuItem1.Click
        frmABMProducto.MdiParent = Me
        frmABMProducto.Show()

    End Sub

    Private Sub PreciosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreciosToolStripMenuItem.Click
        frmABMProductoPrecios.MdiParent = Me
        frmABMProductoPrecios.Show()
    End Sub

    Private Sub StockToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StockToolStripMenuItem.Click
        frmAMBStock.MdiParent = Me
        frmAMBStock.Show()
    End Sub
    Private Sub ModoManualToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ModoManualToolStripMenuItem.Click
        frmComprobanteEdit.MdiParent = Me
        frmComprobanteEdit.showManualMode()
    End Sub

    Private Sub ModoAutomaticoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ModoAutomaticoToolStripMenuItem.Click
        frmComprobanteEdit.MdiParent = Me
        frmComprobanteEdit.showAutomaticMode()
    End Sub

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim result As MsgBoxResult = MsgBox("¿Iniciar en modo prueba?", vbYesNo, "todoMicroSolutionPack")
        If result = vbYes Then
            NhibernateSessionFactory.testMode = True
            Me.Text = Me.Text + "(MODO DE PRUEBA)"
        End If
        loadConfigs()
    End Sub

    Private Sub ConstantesToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConstantesToolStripMenuItem1.Click
        frmABMConstantes.MdiParent = Me
        frmABMConstantes.Show()
    End Sub
    Private Sub loadConfigs()
        configManager.loadConfiguration()
    End Sub
    Private Sub MenuStrip_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip.ItemClicked

    End Sub

    Private Sub ConfLocalesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConfLocalesToolStripMenuItem.Click
        frmConfig.MdiParent = Me
        frmConfig.Show()
    End Sub

    Private Sub ObtenerCAEToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ObtenerCAEToolStripMenuItem.Click
        frmProcessCAE.MdiParent = Me
        frmProcessCAE.Show()
    End Sub

    Private Sub UltimoComprobanteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltimoComprobanteToolStripMenuItem.Click
        frmUltimoComprobante.MdiParent = Me
        frmUltimoComprobante.Show()
    End Sub
End Class
